package org.example.aop.aspect;

import lombok.extern.slf4j.Slf4j;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class MyAspectDemo {
    @Around("@annotation(org.example.aop.config.MyAspect)")
    public Object doAround(ProceedingJoinPoint joinPoint){
        log.info("do before..");
        Object o = null;
        try {
            o = joinPoint.proceed();
        } catch (Throwable e) {
            log.error("发生异常e:"+e);
        }
        log.info("do after..");
        return o;
        
    }

    @Around("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
    public Object doAround2(ProceedingJoinPoint joinPoint){
        log.info("RequestMapping do before..");
        Object o = null;
        try {
            o = joinPoint.proceed();
        } catch (Throwable e) {
            log.error("RequestMapping 发生异常e:"+e);
        }
        log.info("RequestMapping do after..");
        return o;

    }
}
